{include file="public/header" /}
<blockquote class="layui-elem-quote">
    菜单规则
</blockquote>
<table class="layui-hide" id="treeTable"></table>
{include file="public/footer" /}
<script>
    layui.use(["treeTable", "tableBar", "util", "popup"], function () {
        var treeTable = layui.treeTable;
        var tableBar = layui.tableBar;
        var util = layui.util;
        var popup = layui.popup;

        treeTable.render({
            elem: '#treeTable',
            url: '{:route("admin.menu.query")}',
            method: "post",
            toolbar: '<div><button type="button" class="layui-btn layui-btn-normal layui-btn-xs" kllxs-on="add">添加</button></div>',
            cols: [[
                { type: 'numbers', fixed: 'left', title: "序号" },
                { field: 'name', title: '菜单名称', minWidth: 100, fixed: 'left', align: 'center' },
                { field: 'icon_str', title: '图标', align: 'center', minWidth: 80, templet: '<div><i class="{{= d.icon_str }}"></i></div>' },
                {
                    field: '', title: '标识', align: 'center', templet: function (d) {
                        if (d.is_menu == 1) {
                            return `${d.controller}@${d.method}`;
                        }
                        return "";
                    }
                },
                { field: 'weigh', title: '权重', align: 'center', minWidth: 80, templet: tableBar.number("weigh", "权重") },
                { field: 'status', title: '状态', align: 'center', minWidth: 100, templet: tableBar.switch("status", "正常|隐藏", "normal|hidden") },
                { field: 'create_time', title: '创建时间', align: 'center', hide: true, width: 180 },
                { field: 'update_time', title: '更新时间', align: 'center', hide: true, width: 180 },
                { fixed: "right", title: "操作", width: 100, align: "center", templet: tableBar.more() }
            ]],
            tree: {
                async: {
                    enable: true,
                    url: '{:route("admin.menu.query")}',
                    type: "post",
                    autoParam: ["pid=id"]
                }
            },
            limits: [10, 25, 50, 100],
            page: true,
        })

        tableBar.util({
            edit: '{:route("admin.menu.edit")}',
            del: '{:route("admin.menu.del")}'
        })

        util.on("kllxs-on", {
            add: function () {
                popup.iframe(`{:route("admin.menu.add")}`)
            }
        })

    })
</script>